home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cproto / patch7.lha / patch7 < prev   
Text File  |  1993-08-08  |  32KB  |  1,179 lines

  1. diff  -c2 old/CHANGES new/CHANGES
  2. *** old/CHANGES    Tue Dec 01 21:03:42 1992
  3. --- new/CHANGES    Tue May 25 21:11:18 1993
  4. ***************
  5. *** 1,4 ****
  6. --- 1,28 ----
  7.   Version 3
  8.   
  9. + Patchlevel 7
  10. + - Fix: The processing of string literals is now more robust.
  11. + - Removed the -f4 option which generated prototypes like
  12. +     int main P_((int argc, char **argv));
  13. +   Use the -m option now to put a guard macro around the prototype
  14. +   parameter list.  Use the -m option together with -f3 (which is the
  15. +   default) to produce the same output as the old -f4 option.  The option
  16. +   to set the guard macro name is now -M.
  17. + - Comments in prototype parameter lists are now disabled by default.
  18. +   Use the -c option now to output these comments.
  19. + - Can now process #include directives in which the file is specified with
  20. +   a #define macro.
  21. + - Now does not convert function definitions that take the formal
  22. +   parameter va_alist from <varargs.h>.
  23. + - Now recognizes the GNU C modifiers __const and __inline__.
  24.   Patchlevel 6
  25.   
  26. diff  -c2 old/config.h new/config.h
  27. *** old/config.h    Sat Nov 28 23:27:44 1992
  28. --- new/config.h    Tue May 25 21:48:48 1993
  29. ***************
  30. *** 1,3 ****
  31. ! /* $Id: config.h 3.5 1992/11/29 04:27:30 cthuang Exp $
  32.    *
  33.    * cproto configuration and system dependencies
  34. --- 1,3 ----
  35. ! /* $Id: config.h 3.6 1993/05/26 01:48:42 cthuang Exp $
  36.    *
  37.    * cproto configuration and system dependencies
  38. ***************
  39. *** 4,8 ****
  40.    */
  41.   
  42. ! /* Borland C predefines __MSDOS__ */
  43.   #ifdef __MSDOS__
  44.   #ifndef MSDOS
  45. --- 4,8 ----
  46.    */
  47.   
  48. ! /* Borland C++ for MS-DOS predefines __MSDOS__ */
  49.   #ifdef __MSDOS__
  50.   #ifndef MSDOS
  51. ***************
  52. *** 11,17 ****
  53. --- 11,29 ----
  54.   #endif
  55.   
  56. + /* Borland C++ for OS/2 predefines __OS2__ */
  57. + #ifdef __OS2__
  58. + #ifndef OS2
  59. + #define OS2
  60. + #endif
  61. + #endif
  62.   /* Turbo C preprocessor */
  63.   #ifdef TURBO_CPP
  64.   #define CPP "cpp -P-"
  65. + #else
  66. + #ifdef OS2
  67. + #define popen _popen
  68. + #define pclose _pclose
  69. + #endif
  70.   #endif
  71.   
  72. ***************
  73. *** 43,47 ****
  74.   #endif
  75.   
  76. ! #if __STDC__ || defined(MSDOS)
  77.   #include <stdlib.h>
  78.   #include <string.h>
  79. --- 55,59 ----
  80.   #endif
  81.   
  82. ! #if __STDC__ || defined(MSDOS) || defined(OS2)
  83.   #include <stdlib.h>
  84.   #include <string.h>
  85. diff  -c2 old/cproto.1 new/cproto.1
  86. *** old/cproto.1    Sat Nov 28 23:34:08 1992
  87. --- new/cproto.1    Tue May 25 21:36:04 1993
  88. ***************
  89. *** 1,3 ****
  90. ! .\" $Id: cproto.1 3.7 1992/11/29 04:34:05 cthuang Exp $
  91.   .\"
  92.   .de EX        \"Begin example
  93. --- 1,3 ----
  94. ! .\" $Id: cproto.1 3.8 1993/05/26 01:34:15 cthuang Exp $
  95.   .\"
  96.   .de EX        \"Begin example
  97. ***************
  98. *** 14,18 ****
  99.   .if t .sp .5
  100.   ..
  101. ! .TH CPROTO 1 "October 24, 1992"
  102.   .SH NAME
  103.   cproto \- generate C function prototypes and convert function definitions
  104. --- 14,18 ----
  105.   .if t .sp .5
  106.   ..
  107. ! .TH CPROTO 1 "May 24, 1993"
  108.   .SH NAME
  109.   cproto \- generate C function prototypes and convert function definitions
  110. ***************
  111. *** 96,100 ****
  112.   Set the style of generated function prototypes where
  113.   .I n
  114. ! is a number from 0 to 4.
  115.   For example, consider the function definition
  116.   .EX
  117. --- 96,100 ----
  118.   Set the style of generated function prototypes where
  119.   .I n
  120. ! is a number from 0 to 3.
  121.   For example, consider the function definition
  122.   .EX
  123. ***************
  124. *** 119,123 ****
  125.   int main(int argc, char *argv[]);
  126.   .EE
  127. ! A value of 4 produces prototypes guarded by a macro:
  128.   .EX
  129.   int main P_((int argc, char *argv[]));
  130. --- 119,131 ----
  131.   int main(int argc, char *argv[]);
  132.   .EE
  133. ! .TP
  134. ! .B \-c
  135. ! The parameter comments in the prototypes generated by
  136. ! the \-f1 and \-f2 options are omitted by default.
  137. ! Use this option to enable the output of these comments.
  138. ! .TP
  139. ! .B \-m
  140. ! Put a macro around the parameter list of every generated prototype.
  141. ! For example:
  142.   .EX
  143.   int main P_((int argc, char *argv[]));
  144. ***************
  145. *** 124,139 ****
  146.   .EE
  147.   .TP
  148. ! .B \-c
  149. ! Omit the parameter comments in the prototypes generated by
  150. ! the \-f1 and \-f2 options.
  151. ! This option also omits the comments naming the source files from which
  152. ! the prototypes were generated.
  153. ! .TP
  154. ! .BI \-m name
  155. ! Set the name of the macro used to guard prototypes when option \-f4 is selected.
  156.   The default is "P_".
  157.   .TP
  158.   .B \-d
  159. ! Omit the definition of the prototype macro named by the \-m option.
  160.   .TP
  161.   .B \-p
  162. --- 132,142 ----
  163.   .EE
  164.   .TP
  165. ! .BI \-M name
  166. ! Set the name of the macro used to surround prototype parameter lists
  167. ! when option \-m is selected.
  168.   The default is "P_".
  169.   .TP
  170.   .B \-d
  171. ! Omit the definition of the prototype macro used by the \-m option.
  172.   .TP
  173.   .B \-p
  174. ***************
  175. *** 256,259 ****
  176. --- 259,264 ----
  177.   The environment variable CPROTO is scanned for
  178.   a list of options in the same format as the command line options.
  179. + Options given on the command line override any corresponding
  180. + environment option.
  181.   .SH BUGS
  182.   If an untagged struct, union or enum declaration appears in
  183. diff  -c2 old/cproto.c new/cproto.c
  184. *** old/cproto.c    Sat Nov 28 23:27:52 1992
  185. --- new/cproto.c    Tue May 25 21:36:46 1993
  186. ***************
  187. *** 1,3 ****
  188. ! /* $Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $
  189.    *
  190.    * C function prototype generator and function definition converter
  191. --- 1,3 ----
  192. ! /* $Id: cproto.c 3.8 1993/05/26 01:36:41 cthuang Exp $
  193.    *
  194.    * C function prototype generator and function definition converter
  195. ***************
  196. *** 4,8 ****
  197.    */
  198.   #ifndef lint
  199. ! static char rcsid[] = "$Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $";
  200.   #endif
  201.   #include <stdio.h>
  202. --- 4,8 ----
  203.    */
  204.   #ifndef lint
  205. ! static char rcsid[] = "$Id: cproto.c 3.8 1993/05/26 01:36:41 cthuang Exp $";
  206.   #endif
  207.   #include <stdio.h>
  208. ***************
  209. *** 39,42 ****
  210. --- 39,45 ----
  211.   FuncDefStyle func_style = FUNC_NONE;
  212.   
  213. + /* If TRUE, put guard macro around prototype parameters */
  214. + boolean proto_macro = FALSE;
  215.   /* Name of macro to guard prototypes */
  216.   char *macro_name = "P_";
  217. ***************
  218. *** 46,50 ****
  219.   
  220.   /* If TRUE, output comments in prototypes */
  221. ! boolean proto_comments = TRUE;
  222.   
  223.   /* Conditional compilation directive output in front of function definitions */
  224. --- 49,56 ----
  225.   
  226.   /* If TRUE, output comments in prototypes */
  227. ! boolean proto_comments = FALSE;
  228. ! /* If TRUE, output comments naming source files */
  229. ! boolean file_comments = TRUE;
  230.   
  231.   /* Conditional compilation directive output in front of function definitions */
  232. ***************
  233. *** 231,237 ****
  234.       fputs("  -a, -t           Convert function definitions to ANSI or traditional style\n", stderr);
  235.       fputs("  -b               Rewrite function definitions in both styles\n", stderr);
  236. !     fputs("  -c               Omit comments in generated prototypes\n", stderr);
  237.       fputs("  -e               Output \"extern\" keyword before global declarations\n", stderr);
  238. !     fputs("  -f n             Set function prototype style (0 to 4)\n", stderr);
  239.       fputs("  -p               Disable formal parameter promotion\n", stderr);
  240.       fputs("  -q               Disable include file read failure messages\n", stderr);
  241. --- 237,243 ----
  242.       fputs("  -a, -t           Convert function definitions to ANSI or traditional style\n", stderr);
  243.       fputs("  -b               Rewrite function definitions in both styles\n", stderr);
  244. !     fputs("  -c               Enable comments in prototype parameters\n", stderr);
  245.       fputs("  -e               Output \"extern\" keyword before global declarations\n", stderr);
  246. !     fputs("  -f n             Set function prototype style (0 to 3)\n", stderr);
  247.       fputs("  -p               Disable formal parameter promotion\n", stderr);
  248.       fputs("  -q               Disable include file read failure messages\n", stderr);
  249. ***************
  250. *** 238,242 ****
  251.       fputs("  -s               Output static declarations\n", stderr);
  252.       fputs("  -v               Output variable declarations\n", stderr);
  253. !     fputs("  -m name          Set name of prototype macro\n", stderr);
  254.       fputs("  -d               Omit prototype macro definition\n", stderr);
  255.       fputs("  -P template      Set prototype format template \" int f (a, b)\"\n", stderr);
  256. --- 244,249 ----
  257.       fputs("  -s               Output static declarations\n", stderr);
  258.       fputs("  -v               Output variable declarations\n", stderr);
  259. !     fputs("  -m               Put macro around prototype parameters\n", stderr);
  260. !     fputs("  -M name          Set name of prototype macro\n", stderr);
  261.       fputs("  -d               Omit prototype macro definition\n", stderr);
  262.       fputs("  -P template      Set prototype format template \" int f (a, b)\"\n", stderr);
  263. ***************
  264. *** 297,301 ****
  265.   #endif
  266.   
  267. !     while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:m:P:pqstU:Vv")) != EOF) {
  268.       switch (c) {
  269.       case 'I':
  270. --- 304,308 ----
  271.   #endif
  272.   
  273. !     while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:mM:P:pqstU:Vv")) != EOF) {
  274.       switch (c) {
  275.       case 'I':
  276. ***************
  277. *** 323,327 ****
  278.           break;
  279.       case 'c':
  280. !         proto_comments = FALSE;
  281.           break;
  282.       case 'd':
  283. --- 330,334 ----
  284.           break;
  285.       case 'c':
  286. !         proto_comments = TRUE;
  287.           break;
  288.       case 'd':
  289. ***************
  290. *** 387,394 ****
  291.       case 'f':
  292.           proto_style = atoi(optarg);
  293. !         if (proto_style < 0 || proto_style > PROTO_MACRO)
  294.           usage();
  295.           break;
  296.       case 'm':
  297.           macro_name = optarg;
  298.           break;
  299. --- 394,404 ----
  300.       case 'f':
  301.           proto_style = atoi(optarg);
  302. !         if (proto_style < 0 || proto_style > PROTO_ANSI)
  303.           usage();
  304.           break;
  305.       case 'm':
  306. +         proto_macro = TRUE;
  307. +         break;
  308. +     case 'M':
  309.           macro_name = optarg;
  310.           break;
  311. ***************
  312. *** 431,435 ****
  313.       process_options(&argc, &argv);
  314.   
  315. !     if (proto_style == PROTO_MACRO && define_macro) {
  316.       printf("#if __STDC__ || defined(__cplusplus)\n");
  317.       printf("#define %s(s) s\n", macro_name);
  318. --- 441,445 ----
  319.       process_options(&argc, &argv);
  320.   
  321. !     if (proto_macro && define_macro) {
  322.       printf("#if __STDC__ || defined(__cplusplus)\n");
  323.       printf("#define %s(s) s\n", macro_name);
  324. ***************
  325. *** 444,448 ****
  326.           proto_style = PROTO_NONE;
  327.           variables_out = FALSE;
  328. !         proto_comments = FALSE;
  329.       }
  330.       process_file(stdin, "stdin");
  331. --- 454,458 ----
  332.           proto_style = PROTO_NONE;
  333.           variables_out = FALSE;
  334. !         file_comments = FALSE;
  335.       }
  336.       process_file(stdin, "stdin");
  337. ***************
  338. *** 484,488 ****
  339.       }
  340.   
  341. !     if (proto_style == PROTO_MACRO && define_macro) {
  342.       printf("\n#undef %s\n", macro_name);
  343.       }
  344. --- 494,498 ----
  345.       }
  346.   
  347. !     if (proto_macro && define_macro) {
  348.       printf("\n#undef %s\n", macro_name);
  349.       }
  350. diff  -c2 old/cproto.h new/cproto.h
  351. *** old/cproto.h    Sat Nov 28 23:27:46 1992
  352. --- new/cproto.h    Tue May 25 21:36:26 1993
  353. ***************
  354. *** 1,3 ****
  355. ! /* $Id: cproto.h 3.6 1992/11/29 04:27:30 cthuang Exp $
  356.    *
  357.    * Declarations for C function prototype generator
  358. --- 1,3 ----
  359. ! /* $Id: cproto.h 3.7 1993/05/26 01:36:04 cthuang Exp $
  360.    *
  361.    * Declarations for C function prototype generator
  362. ***************
  363. *** 92,96 ****
  364.   #define PROTO_ABSTRACT        2    /* comment out parameter names */
  365.   #define PROTO_ANSI        3    /* ANSI C prototype */
  366. - #define PROTO_MACRO        4    /* macro around parameters */
  367.   typedef int PrototypeStyle;
  368.   
  369. --- 92,95 ----
  370. ***************
  371. *** 125,131 ****
  372. --- 124,132 ----
  373.   extern PrototypeStyle proto_style;
  374.   extern FuncDefStyle func_style;
  375. + extern boolean proto_macro;
  376.   extern boolean define_macro;
  377.   extern char *macro_name;
  378.   extern boolean proto_comments;
  379. + extern boolean file_comments;
  380.   extern boolean quiet;
  381.   extern char *func_directive;
  382. diff  -c2 old/grammar.y new/grammar.y
  383. *** old/grammar.y    Sat Nov 28 23:27:42 1992
  384. --- new/grammar.y    Tue May 25 21:48:44 1993
  385. ***************
  386. *** 1,3 ****
  387. ! /* $Id: grammar.y 3.7 1992/11/29 04:27:30 cthuang Exp $
  388.    *
  389.    * yacc grammar for C function prototype generator
  390. --- 1,3 ----
  391. ! /* $Id: grammar.y 3.8 1993/05/26 01:48:42 cthuang Exp $
  392.    *
  393.    * yacc grammar for C function prototype generator
  394. ***************
  395. *** 8,12 ****
  396.   %token <text> '(' '*'
  397.       /* identifiers that are not reserved words */
  398. !     T_IDENTIFIER T_TYPEDEF_NAME
  399.   
  400.       /* storage class */
  401. --- 8,12 ----
  402.   %token <text> '(' '*'
  403.       /* identifiers that are not reserved words */
  404. !     T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
  405.   
  406.       /* storage class */
  407. ***************
  408. *** 92,95 ****
  409. --- 92,98 ----
  410.   static SymbolTable *typedef_names;
  411.   
  412. + /* table of define names */
  413. + static SymbolTable *define_names;
  414.   /* table of type qualifiers */
  415.   static SymbolTable *type_qualifiers;
  416. ***************
  417. *** 196,200 ****
  418.           if (strcmp($1->text, $1->name) != 0)
  419.           flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
  420. !         new_symbol(typedef_names, $1->name, flags);
  421.           free_declarator($1);
  422.       }
  423. --- 199,203 ----
  424.           if (strcmp($1->text, $1->name) != 0)
  425.           flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
  426. !         new_symbol(typedef_names, $1->name, NULL, flags);
  427.           free_declarator($1);
  428.       }
  429. ***************
  430. *** 205,209 ****
  431.           if (strcmp($3->text, $3->name) != 0)
  432.           flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
  433. !         new_symbol(typedef_names, $3->name, flags);
  434.           free_declarator($3);
  435.       }
  436. --- 208,212 ----
  437.           if (strcmp($3->text, $3->name) != 0)
  438.           flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
  439. !         new_symbol(typedef_names, $3->name, NULL, flags);
  440.           free_declarator($3);
  441.       }
  442. ***************
  443. *** 346,349 ****
  444. --- 349,359 ----
  445.           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
  446.       }
  447. +     | T_TYPEDEF_NAME
  448. +     {
  449. +         Symbol *s;
  450. +         s = find_symbol(typedef_names, $1.text);
  451. +         if (s != NULL)
  452. +         new_decl_spec(&$$, $1.text, $1.begin, s->flags);
  453. +     }
  454.       | struct_or_union_specifier
  455.       | enum_specifier
  456. ***************
  457. *** 355,367 ****
  458.           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
  459.       }
  460. !     | T_TYPEDEF_NAME
  461.       {
  462. !         /* A typedef name is actually a type specifier, but since the
  463. !          * typedef symbol table also stores #define names, this production
  464. !          * is here so the <pointer> nonterminal will scan #define names.
  465.            */
  466.           Symbol *s;
  467. !         s = find_symbol(typedef_names, $1.text);
  468. !         new_decl_spec(&$$, $1.text, $1.begin, s->flags);
  469.       }
  470.       ;
  471. --- 365,377 ----
  472.           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
  473.       }
  474. !     | T_DEFINE_NAME
  475.       {
  476. !         /* This rule allows the <pointer> nonterminal to scan #define
  477. !          * names as if they were type modifiers.
  478.            */
  479.           Symbol *s;
  480. !         s = find_symbol(define_names, $1.text);
  481. !         if (s != NULL)
  482. !         new_decl_spec(&$$, $1.text, $1.begin, s->flags);
  483.       }
  484.       ;
  485. ***************
  486. *** 665,669 ****
  487.   %%
  488.   
  489. ! #ifdef MSDOS
  490.   #include "lex_yy.c"
  491.   #else
  492. --- 675,679 ----
  493.   %%
  494.   
  495. ! #if defined(MSDOS) || defined(OS2)
  496.   #include "lex_yy.c"
  497.   #else
  498. ***************
  499. *** 688,692 ****
  500.       static char *keywords[] = {
  501.       "const", "volatile", "interrupt",
  502. ! #ifdef MSDOS
  503.       "cdecl", "far", "huge", "near", "pascal",
  504.       "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
  505. --- 698,702 ----
  506.       static char *keywords[] = {
  507.       "const", "volatile", "interrupt",
  508. ! #if defined(MSDOS) || defined(OS2)
  509.       "cdecl", "far", "huge", "near", "pascal",
  510.       "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
  511. ***************
  512. *** 696,700 ****
  513.       "__inline", "__interrupt", "__loadds", "__near", "__pascal",
  514.       "__saveregs", "__segment", "__stdcall", "__syscall",
  515. !     "__cs", "__ds", "__es", "__ss", "__seg",
  516.   #endif
  517.       };
  518. --- 706,714 ----
  519.       "__inline", "__interrupt", "__loadds", "__near", "__pascal",
  520.       "__saveregs", "__segment", "__stdcall", "__syscall",
  521. ! #ifdef OS2
  522. !     "__far16",
  523. ! #endif
  524. ! #else
  525. !     "__const", "__inline__",
  526.   #endif
  527.       };
  528. ***************
  529. *** 704,708 ****
  530.       type_qualifiers = new_symbol_table();
  531.       for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
  532. !     new_symbol(type_qualifiers, keywords[i], DS_NONE);
  533.       }
  534.   }
  535. --- 718,722 ----
  536.       type_qualifiers = new_symbol_table();
  537.       for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
  538. !     new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
  539.       }
  540.   }
  541. ***************
  542. *** 725,729 ****
  543.           if (*s == 'l' || *s == 'y')
  544.           BEGIN LEXYACC;
  545. ! #ifdef MSDOS
  546.           if (*s == 'L' || *s == 'Y')
  547.           BEGIN LEXYACC;
  548. --- 739,743 ----
  549.           if (*s == 'l' || *s == 'y')
  550.           BEGIN LEXYACC;
  551. ! #if defined(MSDOS) || defined(OS2)
  552.           if (*s == 'L' || *s == 'Y')
  553.           BEGIN LEXYACC;
  554. ***************
  555. *** 734,737 ****
  556. --- 748,752 ----
  557.       included_files = new_symbol_table();
  558.       typedef_names = new_symbol_table();
  559. +     define_names = new_symbol_table();
  560.       inc_depth = -1;
  561.       curly = 0;
  562. ***************
  563. *** 740,746 ****
  564.       yyin = infile;
  565.       include_file(name, func_style != FUNC_NONE);
  566. !     if (proto_comments)
  567.       printf("/* %s */\n", cur_file_name());
  568.       yyparse();
  569.       free_symbol_table(typedef_names);
  570.       free_symbol_table(included_files);
  571. --- 755,762 ----
  572.       yyin = infile;
  573.       include_file(name, func_style != FUNC_NONE);
  574. !     if (file_comments)
  575.       printf("/* %s */\n", cur_file_name());
  576.       yyparse();
  577. +     free_symbol_table(define_names);
  578.       free_symbol_table(typedef_names);
  579.       free_symbol_table(included_files);
  580. diff  -c2 old/lex.l new/lex.l
  581. *** old/lex.l    Tue Dec 01 21:04:42 1992
  582. --- new/lex.l    Tue May 25 21:36:16 1993
  583. ***************
  584. *** 1,4 ****
  585.   %{
  586. ! /* $Id: lex.l 3.9 1992/12/02 02:04:35 cthuang Exp $
  587.    *
  588.    * Lexical analyzer for C function prototype generator
  589. --- 1,4 ----
  590.   %{
  591. ! /* $Id: lex.l 3.10 1993/05/26 01:36:04 cthuang Exp $
  592.    *
  593.    * Lexical analyzer for C function prototype generator
  594. ***************
  595. *** 34,38 ****
  596.   DIGIT        [0-9]
  597.   ID        {LETTER}({LETTER}|{DIGIT})*
  598. ! STRING        \"(\\\"|[^"])*\"
  599.   QUOTED        ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
  600.   
  601. --- 34,38 ----
  602.   DIGIT        [0-9]
  603.   ID        {LETTER}({LETTER}|{DIGIT})*
  604. ! STRING        \"(\\.|\\\n|[^"\\])*\"
  605.   QUOTED        ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
  606.   
  607. ***************
  608. *** 56,76 ****
  609.   
  610.   <CPP1>define{WS}+{ID}    {
  611. !                 save_text();
  612. !                 sscanf(yytext, "define %s", buf);
  613. !                 get_cpp_directive();
  614. !                 new_symbol(typedef_names, buf, DS_EXTERN);
  615. !             }
  616.   
  617. - <CPP1>include{WS}*\"[^"]+\"     {
  618.                   save_text();
  619. !                 sscanf(yytext, "include \"%[^\"]\"", buf);
  620. !                 get_cpp_directive();
  621. !                 do_include(buf, FALSE);
  622.               }
  623. ! <CPP1>include{WS}*\<[^>]+\>    {
  624.                   save_text();
  625. !                 sscanf(yytext, "include <%[^>]>", buf);
  626. !                 get_cpp_directive();
  627. !                 do_include(buf, TRUE);
  628.               }
  629.   
  630. --- 56,81 ----
  631.   
  632.   <CPP1>define{WS}+{ID}    {
  633. !                 char name[MAX_TEXT_SIZE], value[MAX_TEXT_SIZE];
  634.   
  635.                   save_text();
  636. !                 sscanf(yytext, "define %s", name);
  637. !                 get_cpp_directive(buf, sizeof(buf));
  638. !                 sscanf(buf, "%s", value);
  639. !                 new_symbol(define_names, name, value, DS_NONE);
  640.               }
  641. ! <CPP1>include{WS}*    {
  642.                   save_text();
  643. !                 get_cpp_directive(buf, sizeof(buf));
  644. !                 if (buf[0] != '"' && buf[0] != '<') {
  645. !                 Symbol *sym = find_symbol(define_names, buf);
  646. !                 if (sym != NULL && sym->value != NULL) {
  647. !                     strcpy(buf, sym->value);
  648. !                 } else {
  649. !                     buf[0] = '\0';
  650. !                 }
  651. !                 }
  652. !                 if (buf[0] != '\0')
  653. !                 do_include(buf);
  654.               }
  655.   
  656. ***************
  657. *** 96,100 ****
  658.               }
  659.   
  660. ! <CPP1>.         { save_text(); get_cpp_directive(); }
  661.   
  662.   <INITIAL>"("        { save_text_offset(); return '('; }
  663. --- 101,105 ----
  664.               }
  665.   
  666. ! <CPP1>.         { save_text(); get_cpp_directive(NULL, 0); }
  667.   
  668.   <INITIAL>"("        { save_text_offset(); return '('; }
  669. ***************
  670. *** 156,159 ****
  671. --- 161,166 ----
  672.                   else if (find_symbol(typedef_names, yytext) != NULL)
  673.                   return T_TYPEDEF_NAME;
  674. +                 else if (find_symbol(define_names, yytext) != NULL)
  675. +                 return T_DEFINE_NAME;
  676.                   else
  677.                   return T_IDENTIFIER;
  678. ***************
  679. *** 290,302 ****
  680.   }
  681.   
  682. ! /* Scan rest of preprocessor directive.
  683.    */
  684.   static void
  685. ! get_cpp_directive ()
  686.   {
  687. -     static char cont_trigraph[] = { '?', '?', '/', '\0' };
  688.       char c, lastc[4];
  689.       
  690.       lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
  691.   
  692.       while ((c = input()) != 0) {
  693. --- 297,313 ----
  694.   }
  695.   
  696. ! /* Scan rest of preprocessor directive.  If <dest> is not NULL, then store
  697. !  * the text in the buffer pointed to by <dest> having size <n>.
  698.    */
  699.   static void
  700. ! get_cpp_directive (dest, n)
  701. ! char *dest;        /* buffer to store directive text */
  702. ! unsigned n;        /* size of buffer to store directive text */
  703.   {
  704.       char c, lastc[4];
  705.       
  706.       lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
  707. +     if (dest != NULL)
  708. +     *dest = '\0';
  709.   
  710.       while ((c = input()) != 0) {
  711. ***************
  712. *** 303,310 ****
  713.       if (cur_file->convert)
  714.           fputc(c, cur_file->tmp_file);
  715.       switch (c) {
  716.       case '\n':
  717.           cur_file->line_num++;
  718. !         if (lastc[2] != '\\' && strcmp(lastc, cont_trigraph) != 0) {
  719.           BEGIN INITIAL;
  720.           return;
  721. --- 314,322 ----
  722.       if (cur_file->convert)
  723.           fputc(c, cur_file->tmp_file);
  724.       switch (c) {
  725.       case '\n':
  726.           cur_file->line_num++;
  727. !         if (lastc[2] != '\\' && strcmp(lastc, "?\?/") != 0) {
  728.           BEGIN INITIAL;
  729.           return;
  730. ***************
  731. *** 319,322 ****
  732. --- 331,340 ----
  733.       lastc[1] = lastc[2];
  734.       lastc[2] = c;
  735. +     if (dest != NULL && n > 1) {
  736. +         *dest++ = c;
  737. +         *dest = '\0';
  738. +         --n;
  739. +     }
  740.       }
  741.   }
  742. ***************
  743. *** 509,518 ****
  744.    */
  745.   static void
  746. ! do_include (filename, stdinc)
  747. ! char *filename;     /* file to include */
  748. ! boolean stdinc;     /* TRUE if file name specified with angle brackets */
  749.   {
  750. !     char path[MAX_TEXT_SIZE];
  751.       int i;
  752.       FILE *fp;
  753.   
  754. --- 527,538 ----
  755.    */
  756.   static void
  757. ! do_include (file_spec)
  758. ! char *file_spec;     /* path surrounded by "" or <> */
  759.   {
  760. !     int stdinc;     /* 1 = path surrounded by <> */
  761. !     char file[MAX_TEXT_SIZE], path[MAX_TEXT_SIZE];
  762. !     char match, *s;
  763.       int i;
  764. +     unsigned n;
  765.       FILE *fp;
  766.   
  767. ***************
  768. *** 523,536 ****
  769.       }
  770.   
  771. !     sprintf(path, stdinc ? "<%s>" : "\"%s\"", filename);
  772.       if (find_symbol(included_files, path) != NULL)
  773.       return;
  774. !     new_symbol(included_files, path, 0);
  775.   
  776.       for (i = stdinc != 0; i < num_inc_dir; ++i) {
  777.       if (strlen(inc_dir[i]) == 0) {
  778. !         strcpy(path, filename);
  779.       } else {
  780. !         sprintf(path, "%s/%s", inc_dir[i], filename);
  781.       }
  782.       if ((fp = fopen(path, "r")) != NULL) {
  783. --- 543,571 ----
  784.       }
  785.   
  786. !     if (file_spec[0] == '"') {
  787. !     match = '"';
  788. !     stdinc = 0;
  789. !     } else if (file_spec[0] == '<') {
  790. !     match = '>';
  791. !     stdinc = 1;
  792. !     } else {
  793. !     return;
  794. !     }
  795. !     s = strchr(file_spec+1, match);
  796. !     n = (s != NULL) ? (unsigned)(s - file_spec - 1) : 0;
  797. !     strncpy(file, file_spec+1, n);
  798. !     file[n] = '\0';
  799. !     /* Do nothing if the file was already included. */
  800. !     sprintf(path, stdinc ? "<%s>" : "\"%s\"", file);
  801.       if (find_symbol(included_files, path) != NULL)
  802.       return;
  803. !     new_symbol(included_files, path, NULL, DS_NONE);
  804.   
  805.       for (i = stdinc != 0; i < num_inc_dir; ++i) {
  806.       if (strlen(inc_dir[i]) == 0) {
  807. !         strcpy(path, file);
  808.       } else {
  809. !         sprintf(path, "%s/%s", inc_dir[i], file);
  810.       }
  811.       if ((fp = fopen(path, "r")) != NULL) {
  812. ***************
  813. *** 543,547 ****
  814.       if (!quiet) {
  815.       put_error();
  816. !     fprintf(stderr, "cannot read file %s\n", filename);
  817.       }
  818.   }
  819. --- 578,582 ----
  820.       if (!quiet) {
  821.       put_error();
  822. !     fprintf(stderr, "cannot read file %s\n", file_spec);
  823.       }
  824.   }
  825. diff  -c2 old/Makefile.bc new/Makefile.bc
  826. *** old/Makefile.bc    Sat Nov 28 23:27:32 1992
  827. --- new/Makefile.bc    Tue May 25 21:36:04 1993
  828. ***************
  829. *** 1,3 ****
  830. ! # $Id: Makefile.bc 3.1 1992/03/03 10:45:53 cthuang Exp $
  831.   #
  832.   # Borland C++ makefile for C prototype generator
  833. --- 1,3 ----
  834. ! # $Id: Makefile.bc 3.2 1993/05/26 01:34:15 cthuang Exp $
  835.   #
  836.   # Borland C++ makefile for C prototype generator
  837. ***************
  838. *** 10,14 ****
  839.   YACC = yacc
  840.   CC = bcc
  841. ! CFLAGS = -mc $(DEFINES)
  842.   LIBS = \bc\lib\wildargs.obj
  843.   
  844. --- 10,14 ----
  845.   YACC = yacc
  846.   CC = bcc
  847. ! CFLAGS = -mc $(DEFINES) -w-pin -w-pro
  848.   LIBS = \bc\lib\wildargs.obj
  849.   
  850. ***************
  851. *** 50,65 ****
  852.   
  853.   shar:
  854. -     rmcr $(DIST1) $(DIST2)
  855. -     rmcr $(DIST3) $(DIST4)
  856.       shar $(DIST1) $(DIST2) >cproto.sh1
  857.       shar $(DIST3) $(DIST4) >cproto.sh2
  858.   
  859. - inscr:
  860. -     inscr $(DIST1) $(DIST2)
  861. -     inscr $(DIST3) $(DIST4)
  862.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  863.   
  864. ! cproto.obj: config.h cproto.h symbol.h
  865.   popen.obj: config.h cproto.h
  866.   semantic.obj: config.h cproto.h symbol.h semantic.h
  867. --- 50,59 ----
  868.   
  869.   shar:
  870.       shar $(DIST1) $(DIST2) >cproto.sh1
  871.       shar $(DIST3) $(DIST4) >cproto.sh2
  872.   
  873.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  874.   
  875. ! cproto.obj: config.h cproto.h
  876.   popen.obj: config.h cproto.h
  877.   semantic.obj: config.h cproto.h symbol.h semantic.h
  878. diff  -c2 old/Makefile.msc new/Makefile.msc
  879. *** old/Makefile.msc    Sat Nov 28 23:27:36 1992
  880. --- new/Makefile.msc    Tue May 25 21:36:12 1993
  881. ***************
  882. *** 1,3 ****
  883. ! # $Id: Makefile.msc 3.4 1992/11/29 04:27:30 cthuang Exp $
  884.   #
  885.   # Microsoft C makefile for C prototype generator
  886. --- 1,3 ----
  887. ! # $Id: Makefile.msc 3.5 1993/05/26 01:36:04 cthuang Exp $
  888.   #
  889.   # Microsoft C makefile for C prototype generator
  890. ***************
  891. *** 51,66 ****
  892.   
  893.   shar:
  894. -     rmcr $(DIST1) $(DIST2)
  895. -     rmcr $(DIST3) $(DIST4)
  896.       shar $(DIST1) $(DIST2) >cproto.sh1
  897.       shar $(DIST3) $(DIST4) >cproto.sh2
  898.   
  899. - inscr:
  900. -     inscr $(DIST1) $(DIST2)
  901. -     inscr $(DIST3) $(DIST4)
  902.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  903.   
  904. ! cproto.obj: config.h cproto.h symbol.h
  905.   popen.obj: config.h cproto.h
  906.   semantic.obj: config.h cproto.h symbol.h semantic.h
  907. --- 51,60 ----
  908.   
  909.   shar:
  910.       shar $(DIST1) $(DIST2) >cproto.sh1
  911.       shar $(DIST3) $(DIST4) >cproto.sh2
  912.   
  913.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  914.   
  915. ! cproto.obj: config.h cproto.h
  916.   popen.obj: config.h cproto.h
  917.   semantic.obj: config.h cproto.h symbol.h semantic.h
  918. diff  -c2 old/Makefile.uni new/Makefile.uni
  919. *** old/Makefile.uni    Sat Nov 28 23:27:36 1992
  920. --- new/Makefile.uni    Tue May 25 21:36:12 1993
  921. ***************
  922. *** 1,3 ****
  923. ! # $Id: Makefile.uni 3.5 1992/06/10 20:56:00 cthuang Exp $
  924.   #
  925.   # UNIX makefile for C prototype generator
  926. --- 1,3 ----
  927. ! # $Id: Makefile.uni 3.6 1993/05/26 01:34:15 cthuang Exp $
  928.   #
  929.   # UNIX makefile for C prototype generator
  930. ***************
  931. *** 47,51 ****
  932.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  933.   
  934. ! cproto.o: config.h cproto.h symbol.h
  935.   semantic.o: config.h cproto.h symbol.h semantic.h
  936.   strstr.o: config.h
  937. --- 47,51 ----
  938.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  939.   
  940. ! cproto.o: config.h cproto.h
  941.   semantic.o: config.h cproto.h symbol.h semantic.h
  942.   strstr.o: config.h
  943. diff  -c2 old/patchlev.h new/patchlev.h
  944. *** old/patchlev.h    Tue Dec 01 09:52:28 1992
  945. --- new/patchlev.h    Wed Dec 02 21:16:22 1992
  946. ***************
  947. *** 1 ****
  948. ! #define PATCHLEVEL 6
  949. --- 1 ----
  950. ! #define PATCHLEVEL 7
  951. diff  -c2 old/semantic.c new/semantic.c
  952. *** old/semantic.c    Sat Nov 28 23:27:56 1992
  953. --- new/semantic.c    Tue May 25 21:36:50 1993
  954. ***************
  955. *** 1,3 ****
  956. ! /* $Id: semantic.c 3.7 1992/11/29 04:27:49 cthuang Exp $
  957.    *
  958.    * Semantic actions executed by the parser of the
  959. --- 1,3 ----
  960. ! /* $Id: semantic.c 3.8 1993/05/26 01:36:41 cthuang Exp $
  961.    *
  962.    * Semantic actions executed by the parser of the
  963. ***************
  964. *** 519,524 ****
  965.       fputs(s, outf);
  966.   
  967. !     if (where == FUNC_PROTO && proto_style == PROTO_MACRO &&
  968. !      declarator == func_declarator) {
  969.       fprintf(outf, " %s(", macro_name);
  970.       }
  971. --- 519,523 ----
  972.       fputs(s, outf);
  973.   
  974. !     if (where == FUNC_PROTO && declarator == func_declarator && proto_macro) {
  975.       fprintf(outf, " %s(", macro_name);
  976.       }
  977. ***************
  978. *** 529,534 ****
  979.       fputs(t, outf);
  980.   
  981. !     if (where == FUNC_PROTO && proto_style == PROTO_MACRO &&
  982. !      declarator == func_declarator) {
  983.       fputc(')', outf);
  984.       }
  985. --- 528,532 ----
  986.       fputs(t, outf);
  987.   
  988. !     if (where == FUNC_PROTO && declarator == func_declarator && proto_macro) {
  989.       fputc(')', outf);
  990.       }
  991. ***************
  992. *** 608,616 ****
  993.   }
  994.   
  995. ! /* Generate a prototype for a function that uses varargs by replacing the
  996. !  * "va_alist" parameter with an empty parameter list.
  997.    */
  998. ! static void
  999. ! check_varargs (declarator)
  1000.   Declarator *declarator;
  1001.   {
  1002. --- 606,613 ----
  1003.   }
  1004.   
  1005. ! /* Return TRUE if the function uses varargs.
  1006.    */
  1007. ! static int
  1008. ! uses_varargs (declarator)
  1009.   Declarator *declarator;
  1010.   {
  1011. ***************
  1012. *** 617,626 ****
  1013.       Parameter *p;
  1014.   
  1015. !     if ((p = declarator->params.first) != NULL && p->next == NULL &&
  1016. !     strcmp(p->declarator->name, "va_alist") == 0)
  1017. !     {
  1018. !     free_param_list(&declarator->params);
  1019. !     declarator->params.first = NULL;
  1020. !     }
  1021.   }
  1022.   
  1023. --- 614,619 ----
  1024.       Parameter *p;
  1025.   
  1026. !     return (p = declarator->params.first) != NULL && p->next == NULL &&
  1027. !     strcmp(p->declarator->name, "va_alist") == 0;
  1028.   }
  1029.   
  1030. ***************
  1031. *** 673,678 ****
  1032.   
  1033.       func_declarator = declarator->head;
  1034.       check_void_param(func_declarator);
  1035. -     check_varargs(func_declarator);
  1036.       set_param_decl_spec(func_declarator);
  1037.   
  1038. --- 666,678 ----
  1039.   
  1040.       func_declarator = declarator->head;
  1041. +     if (uses_varargs(func_declarator)) {
  1042. +     /* Generate a prototype for a function that uses varargs by replacing
  1043. +      * the "va_alist" parameter with an empty parameter list.
  1044. +      */
  1045. +     free_param_list(&func_declarator->params);
  1046. +     func_declarator->params.first = NULL;
  1047. +     }
  1048.       check_void_param(func_declarator);
  1049.       set_param_decl_spec(func_declarator);
  1050.   
  1051. ***************
  1052. *** 737,743 ****
  1053.       int comment_len, n;
  1054.   
  1055. !     /* Do nothing if the function is already defined in the desired style. */
  1056.       func_declarator = declarator->head;
  1057. !     if (func_declarator->func_def == func_style)
  1058.       return;
  1059.   
  1060. --- 737,746 ----
  1061.       int comment_len, n;
  1062.   
  1063. !     /* Do nothing if the function is already defined in the desired style
  1064. !      * or if the function uses varargs.
  1065. !      */
  1066.       func_declarator = declarator->head;
  1067. !     if (func_declarator->func_def == func_style ||
  1068. !     uses_varargs(func_declarator))
  1069.       return;
  1070.   
  1071. diff  -c2 old/symbol.c new/symbol.c
  1072. *** old/symbol.c    Sat Nov 28 23:28:00 1992
  1073. --- new/symbol.c    Tue May 25 21:36:54 1993
  1074. ***************
  1075. *** 1,3 ****
  1076. ! /* $Id: symbol.c 3.2 1992/11/29 04:27:49 cthuang Exp $
  1077.    *
  1078.    * Implements a symbol table abstract data type.
  1079. --- 1,3 ----
  1080. ! /* $Id: symbol.c 3.3 1993/05/26 01:36:41 cthuang Exp $
  1081.    *
  1082.    * Implements a symbol table abstract data type.
  1083. ***************
  1084. *** 39,42 ****
  1085. --- 39,43 ----
  1086.           next = sym->next;
  1087.           free(sym->name);
  1088. +         free(sym->value);
  1089.           free(sym);
  1090.           sym = next;
  1091. ***************
  1092. *** 98,104 ****
  1093.    */
  1094.   Symbol *
  1095. ! new_symbol (symtab, name, flags)
  1096.   SymbolTable *symtab;    /* symbol table */
  1097.   char *name;        /* symbol name */
  1098.   int flags;        /* symbol attributes */
  1099.   {
  1100. --- 99,106 ----
  1101.    */
  1102.   Symbol *
  1103. ! new_symbol (symtab, name, value, flags)
  1104.   SymbolTable *symtab;    /* symbol table */
  1105.   char *name;        /* symbol name */
  1106. + char *value;        /* symbol value */
  1107.   int flags;        /* symbol attributes */
  1108.   {
  1109. ***************
  1110. *** 109,117 ****
  1111.       sym = (Symbol *)xmalloc(sizeof(Symbol));
  1112.       sym->name = xstrdup(name);
  1113. -     sym->flags = flags;
  1114.       i = hash(name);
  1115.       sym->next = symtab->bucket[i];
  1116.       symtab->bucket[i] = sym;
  1117.       }
  1118.       return sym;
  1119.   }
  1120. --- 111,122 ----
  1121.       sym = (Symbol *)xmalloc(sizeof(Symbol));
  1122.       sym->name = xstrdup(name);
  1123.       i = hash(name);
  1124.       sym->next = symtab->bucket[i];
  1125.       symtab->bucket[i] = sym;
  1126. +     } else {
  1127. +     free(sym->value);
  1128.       }
  1129. +     sym->value = (value != NULL) ? xstrdup(value) : NULL;
  1130. +     sym->flags = flags;
  1131.       return sym;
  1132.   }
  1133. diff  -c2 old/symbol.h new/symbol.h
  1134. *** old/symbol.h    Sat Nov 28 23:27:48 1992
  1135. --- new/symbol.h    Tue May 25 21:36:40 1993
  1136. ***************
  1137. *** 1,3 ****
  1138. ! /* $Id: symbol.h 3.3 1992/03/14 11:57:48 cthuang Exp $
  1139.    *
  1140.    * A symbol table is a collection of string identifiers stored in a
  1141. --- 1,3 ----
  1142. ! /* $Id: symbol.h 3.4 1993/05/26 01:36:04 cthuang Exp $
  1143.    *
  1144.    * A symbol table is a collection of string identifiers stored in a
  1145. ***************
  1146. *** 10,14 ****
  1147.       struct symbol *next;    /* next symbol in list */
  1148.       char *name;         /* name of symbol */
  1149. !     unsigned short flags;    /* symbol attributes */
  1150.   } Symbol;
  1151.   
  1152. --- 10,15 ----
  1153.       struct symbol *next;    /* next symbol in list */
  1154.       char *name;         /* name of symbol */
  1155. !     char *value;        /* value of symbol (for defines) */
  1156. !     short flags;        /* symbol attributes */
  1157.   } Symbol;
  1158.   
  1159.